﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Assist;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Revit;
using YRevitJig;

namespace YArchitech.Plumbing
{
	public class CreateRiserPipeLinesJig : XUiJigBase
	{
		public XYZ StartPoint { get; set; }

		public CreateRiserPipeLinesJig(UIDocument uiDoc) : base(uiDoc)
		{
		}

		public override void Draw(PaintEventArgs paintEventArgs)
		{
			base.Draw(paintEventArgs);
			if (!this.m_ptCur.IsEmpty && paintEventArgs != null)
			{
				try
				{
					this.resultLines.Clear();
					XYZ xyz = base.Client2Revit(this.m_ptCur);
					XYZ xyz2 = new XYZ(xyz.X, xyz.Y, this.StartPoint.Z);
					if (xyz2.X < this.StartPoint.X)
					{
						this.isLeft = true;
					}
					else
					{
						this.isLeft = false;
					}
					XYZ xyz3 = null;
					XYZ xyz4 = null;
					this.resultLines = MarkRiserPipeUtility.DrawSinglePipeMarkLines(this.StartPoint, xyz2, 0.0, false, Math.Abs(AssistFunc.feetToMM(xyz2.Y - this.StartPoint.Y)), MarkRiserPipeUtility.TextLength, ref xyz3, ref xyz4, base.Doc, this.isLeft);
					XGraphics g = new XGraphics(paintEventArgs.Graphics, base.JigPen);
					foreach (Line curve in this.resultLines)
					{
						new XLine2D(base.Revit2Client(curve.GetEndPoint(0)), base.Revit2Client(curve.GetEndPoint(1))).Draw(g);
					}
				}
				catch (Exception ex)
				{
					ex.ToString();
				}
			}
		}

		public bool isLeft;

		public List<Line> resultLines = new List<Line>();
	}
}
